home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
exkey4.arc
/
EXTKEY.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-01-27
|
5KB
|
169 lines
;┌────────────────────────────────────────────────────────────────────┐
;│ EXTKEY.ASM - INT 16 handler to deal with extended AT keyboard │
;│ │
;│ This routine tests for the presence of an extended 101 or 102 │
;│ key keyboard. If the extended keyboard is detected then this │
;│ routine causes any INT 16 calls to invokes the enhanced keyboard │
;│ handler functions by default instead of the standard routines. │
;│ │
;│ Originally designed for use with Turbo Pascal, though the routines │
;│ may be called by any package as they need no parameters. To use │
;│ these routines simply call the function SetKeyVector at the start │
;│ of your program, and call RestoreKeyVector before leaving. The │
;│ rest is automatic. │
;│ │
;│ (C) Copyright Aubrey Scoon 1990 │
;│ │
;│ Scoon Consultancy Services │
;│ 49 Honeyhill Road, │
;│ Bracknell, │
;│ Berkshire. │
;│ RG12 1YH. │
;│ U.K. │
;│ │
;└────────────────────────────────────────────────────────────────────┘
code segment byte public
assume cs:code
public SetKeyVector,RestoreKeyVector,Ext_Keyboard_Present
;─────────────────────────────────────────────────────────────────────
SetKeyVector proc far
; Install new interrupt handler
mov ah,35h ; get interrupt vector
mov al,16h ; vector to get
int 21h ; DOS call
mov ax,es ; vector segment
mov cs:vectseg,ax ; store it
mov cs:vectofs,bx ; store vector offset
push ds ; save data segment
mov ax,cs
mov ds,ax ; set current segment
mov dx,offset newkey
mov ah,25h ; set interrupt vector
mov al,16h ; vector to set
int 21h
pop ds
ret
; Temporary storage for old interrupt vector
vectofs dw 0
vectseg dw 0
;─────────────────────────────────────────────────────────────────────
; This is the actual new interrupt handler
; First check the function number
newkey:
push ds ; store data segment
push ax ; keep function params
sti ; restart interrupts
cmp ah,03h ; check function
jae oldvect ; if ah>=3 then call old vector
; Function affected so check keyboard
mov ax,0040h ; BIOS data segment
mov ds,ax
mov al,byte ptr ds:[0096h] ; get keyboard state flags
and al,10h ; mask extended flag
jz oldvect ; must be old keyboard
; If we get to here the machine has probably got an extended keyboard
; so we add 10h to the BIOS function number and call the old vector
newcall: pop ax ; get old function no
add ah,10h ; modify function no
cmp ah,12h ; function 12h ?
je ovect2 ; use enhanced function
cli
pushf ; simulate interrupt
call dword ptr cs:[vectofs] ; do INT 16h !
pushf ; save result flags
cmp al,224 ; special key ?
jne exit ; no so quit
cmp ah,0 ; fix for special keys
je exit
mov al,0
exit: popf ; get result flags
pop ds ; restore from stack
sti ; restart interrupts
iret ; end of interrupt
oldvect: pop ax ; pop function no
ovect2: cli ; disable interrupts
pop ds ; restore data segment
jmp dword ptr cs:[vectofs] ; jump to old vector
SetkeyVector endp
;─────────────────────────────────────────────────────────────────────
RestoreKeyVector proc far
; procedure to restore interrupt vector
push ds
mov ax,seg SetKeyVector
mov ds,ax
mov dx,vectofs
mov ax,vectseg ; get old vector
mov ds,ax
mov ah,25h ; set interrupt vector
mov al,16h ; interrupt number
int 21h ; DOS call
pop ds
ret
RestoreKeyVector endp
;─────────────────────────────────────────────────────────────────────
Ext_Keyboard_Present proc far
; Returns boolean flag to indicate presence of enhanced keyboard
push es
mov ax,0040h ; BIOS data segment
mov es,ax
mov al,byte ptr es:[0096h] ; get keyboard state flags
pop es
and al,10h ; mask extended flag
jz fin ; must be old keyboard
mov al,1
fin: ret
Ext_Keyboard_Present endp
code ends
end
;─────────────────────────────────────────────────────────────────────